using UnityEngine;
using System.Collections;



public class AnimationBlend : MonoBehaviour {

	float m_MoveSpeed = 1.0f;
	// Use this for initialization
	void Start () 
	{
        animation.wrapMode = WrapMode.Loop;
		animation["jump"].wrapMode = WrapMode.Clamp;
		animation["jump"].layer = 1;
        animation.Stop();
	}
	
	// Update is called once per frame
	void Update () 
	{			
		// Play either the run or idle animation
		if (Mathf.Abs(Input.GetAxis("Horizontal_L")) > 0.1)
		{
			//animation.CrossFade("walk");
			animation.Blend("walk", 0.7f);
			
			// Play animation backwards when running backwards
			animation["walk"].speed = m_MoveSpeed;
		}
		else
			animation.CrossFade("idle");
		
			// Play the cross fade animation
		if (Input.GetButtonDown ("Jump"))
		{
			animation.CrossFade("jump");
			SendMessage("onJump", SendMessageOptions.DontRequireReceiver);
		}
	}
	
	void SetCurrentSpeed(float p_Speed)
	{
		m_MoveSpeed = p_Speed;
	}
}
